package com.panda.pandawash.util;

import android.util.Log;

import com.panda.pandawash.R;
import com.panda.pandawash.api.ApplicationConstant;

import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by gsoft2-3 on 16-5-30.
 */
public class StringUtil {
    public static final String TAG = "StringUtil_TAG";
    public static Boolean isPhoneNumber(String phonenum){
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(phonenum);
        return m.matches();
    }

    public static Set<String> parsersTag(String content){
        Set<String> set=new LinkedHashSet<>();
        if(content.contains("[")) {
            content = content.substring(1, content.length() - 1).replace(" ","");
            String[] tags = content.split(",");
            for (int i = 0; i < tags.length; i++) {
                if(ApplicationConstant.DEBUG) {
                    Log.d(TAG, tags[i]);
                }
                set.add(tags[i]);
            }
        }
        if(ApplicationConstant.DEBUG) {
            Log.d(TAG, "set size:" + set.size());
        }
        return set;
    }
}
